package com.gome.han.cloud.client.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate;

import com.gome.han.cloud.client.bean.User;

/**
* @author hanpeng
* @version 创建时间：2020年8月30日 下午9:58:07
* @ClassName 类名称
* @Description 类描述
*/
@Controller
public class HelloController {
	@Autowired
	private RestTemplate restTemplate;
	// private static final String REST_URL_PREFIX="http://localhost:8081/";
	private static final String REST_URL_PREFIX = "http://SPRING-CLOUD-PROVIDER1/";
    
	@RequestMapping("/consumer/get/{age}")
	public User home(@PathVariable(name = "age") Integer age) {
		User user = restTemplate.getForObject(REST_URL_PREFIX + "getUser/" + age, User.class);
		return user;
	}
}
